<?php
include "includes/sesiones.php";
include "includes/comunes.php";
//error_reporting(E_ALL);
if($_GET['crear']==1){
     $_SESSION['clinombre']=strtoupper($_GET["nombre"]);
    $_SESSION['cliapellido']=strtoupper($_GET["apellido"]);
    $_SESSION['clidni']=$_GET["dni"];

    header("Location: altacreditos.php");

}


$where=" where 1=1";
if(isset($_POST['Enviar'])){

  if(isset($_POST['nro']) and $_POST['nro']<>"")
      $where.=" and id=".trim($_POST['nro']);
  if(isset($_POST['dni']) and $_POST['dni']<>"")
      $where.=" and Dni='".trim($_POST['dni'])."'";
   if(isset($_POST['ape']) and $_POST['ape']<>"")
      $where.=" and Apellido like '%".trim(strtoupper($_POST['ape']))."%'";
   if(isset($_POST['nom']) and $_POST['nom']<>"")
      $where.=" and Nombre like '%".trim(strtoupper($_POST['nom']))."%'";
   if($_POST['loc']<>0)
      $where.=" and Localidad=".trim($_POST['loc']);
   $sql="select * from clientes ".$where;
   $rescli= cons_ins($sql);

}
else{
$sql="select  * from clientes order by id desc limit 0,15";
$rescli= cons_ins($sql);}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include "includes/metas.php";?>
</head>

<body>
<div class="contenedor">
	<div class="cont">
    	<?php include "includes/head.php";?>
        <?php include "includes/menu.php";?>
        

    	<div class="novedadescont">
            <div class="novedadestitulo">
            <div class="novetitulo2">Listado y Clientes(Seleccione Filtros)</div>
            </div>

                <?php
                  if($_GET['cli_id'])
                      echo '<div class="mensaje">Se ha actualizado el cliente Nº <strong>'.$_GET['cli_id'].'</strong> &nbsp;&nbsp;&nbsp;</div>'
                ?>

            
            <div class="formucont">
                 <form id="form1" name="form1" method="post" action="listadoclientes.php">
           	  <div class="formlinea">

                <div class="formtxt">Nº de Cliente</div>
                <div class="formtxt2">
                    <input name="nro" type="text" id="form" size="25" />
                </div>
                </div>

              <div class="formlinea">
                <div class="formtxt">Dni</div>
                <div class="formtxt2">
                    <input name="dni" type="text" id="form" size="25" />
                </div>
                </div>



              <div class="formlinea">
                <div class="formtxt">Apellido</div>
                <div class="formtxt2">
                    <input name="ape" type="text" id="form" size="25" />
                </div>
                </div>



              <div class="formlinea">
                <div class="formtxt">Nombre</div>
                <div class="formtxt2">
                    <input name="nom" type="text" id="form" size="25" />
                </div>
                </div>



               <div class="formlinea">
                <div class="formtxt">Localidad</div>
                <div class="formtxt2">
                   <?php echo listar_localidades();?>
                </div>
                </div>

                 <div class="botcont">
                <input name="Enviar" class="bot" type="submit" value="Buscar" />
                </div>
                </form>
            </div> 


        	<div class="novedadestitulo">
            	<div class="novetitulo2">Resultado<br>
                </div>
            </div>
            
            <div style="align:left;"> <a href="altaclientes.php"><img src="images/nuevo.png" border="0" width="40px" title="Nuevo Cliente"/></a></div>
            <div class="listadocont">
            	<div class="listadocol2">
                    <table width="700" border="0" >
  <tr class="listadoencabezado">
      <td width="40px"><strong>Nº</strong></td>
      <td width="60px"><strong>DNI</strong></td>
    <td width="250px"><strong>Nombre y Apellido</strong></td>
    <td width="120px"><strong>Can. Cred</strong></td>
    <td width="60px"><strong></strong></td>
    <td>&nbsp;</td>
  </tr>
<?php while ($reg=mysql_fetch_array($rescli)):
       $dni= $reg['Dni'];
        ?>
  <tr class="listadolinea">
    <td class="bordetabla" width="40px"><?php echo $reg['id']?></td>
    <td class="bordetabla" width="58px"><?php echo str_pad($dni,8,'0',STR_PAD_LEFT)?></td>
    <td class="bordetabla" width="290px">&nbsp;<?php echo utf8_encode($reg['Apellido'])." ,".utf8_encode($reg['Nombre']).'-'.obtener_nombre_localidad($reg['Localidad'])?>&nbsp;</td>
    <td class="bordetabla" width="10px">&nbsp;<?php echo obtener_creditos($reg['Dni'])?>&nbsp;</td>
    <td class="bordetabla" width="100px">&nbsp;<a href="valclientes.php?crear=1&nombre=<?php echo utf8_encode($reg['Nombre'])?>&apellido=<?php echo utf8_encode($reg['Apellido'])?>&dni=<?php echo utf8_encode($reg['Dni'])?>"><img src="images/nuevo.png" border="0" width="20px" title="Nuevo Credito"/></a></td>
    <td >
	<?php //if (trim($_SESSION['Usuario'])=="LOLI"):?>
     <a href="editarclientes.php?cli_id=<?php echo $reg['id']?>"><img src="images/editar.png" border="0" width="25px" alt="Editar" title="Editar"/></a> 
	 <?php //endif?>
     <a href="verclientes.php?cli_id=<?php echo $reg['id']?>"><img src="images/visualizar.png" border="0" width="25px" alt="Visualizar" title="Visualizar"/></a>
<!--    <a href="#"><img src="images/ref.png" border="0" width="80px"/></a>-->
    </td>
  </tr>
 <?php

 endwhile ?>


</table>
                	
<!--                    <a href="#" class="listadolinea">Texto o nombre del listado.</a>                    -->
                </div>
<!--                <div class="listadocol">
                	<a href="#"><img src="images/ed.png" border="0" /></a>
                   <a href="#"><img src="images/vis.png" border="0" /></a>
					<a href="#"><img src="images/imp.png" border="0" /></a>
                	<a href="#"><img src="images/ref.png" border="0" /></a>
                    
                    
                </div>-->

                               </div>
            
            
            
            
        	<div class="novedadesbottom"></div>
        </div>
    
    
    
    
    <div class="separador"></div>
  <?php include "includes/menufooter.php";?>
    
    
    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>
</div>
</body>
</html>
